package main

import (
	"fmt"
	"io/ioutil"
	"os"	
)

type Page struct {
	Title string
	Body []byte
}

func ( p *Page ) save() os.Error {
	fileName := p.Title + ".txt"
	return ioutil.WriteFile( fileName, p.Body, 0600 )
}

func loadPage( title string ) ( *Page, os.Error ) {
	fileName := title + ".txt"
	body, err := ioutil.ReadFile( fileName )
    if( nil != err ) {
        return nil, err
    }
    return  &Page{ Title: title, Body: body }, nil
}

func main() {
	pageLocal := &Page{ Title: "TestPage", Body: []byte( "This a sample") }
	pageLocal.save()

	pageLoaded, _ := loadPage( "TestPage" )
	fmt.Println( string( pageLoaded.Body )  )
}
